//
//  CYMyReleaseCell.m
//  CreditAddressBook
//
//  Created by Lee on 15/7/31.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYMyReleaseCell.h"
#import "CYDefaultRecord.h"
#import "CYCreditTool.h"

@interface CYMyReleaseCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *submitStatus;
@property (weak, nonatomic) IBOutlet UILabel *idCardLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *lendLabel;
@property (weak, nonatomic) IBOutlet UILabel *shouldPayTime;
@property (weak, nonatomic) IBOutlet UILabel *lastPayTime;

@end

@implementation CYMyReleaseCell

- (void)setRecord:(CYDefaultRecord *)record {
    _record = record;
    
    self.nameLabel.text = CYStringFormat(@"姓名：%@", record.name);
    self.idCardLabel.text = CYStringFormat(@"身份证号码：%@", record.certificateNo);
    self.phoneLabel.text = CYStringFormat(@"电话：%@", record.phone);
    self.lendLabel.text = CYStringFormat(@"借款金额：%@", record.amountPrice);
    NSString *start = [CYCreditTool timewithLongLongValue:record.startTime.longLongValue formatter:nil];
    self.shouldPayTime.text = CYStringFormat(@"本应还款时间：%@", start);
    if (record.endTime) {
        NSString *end = [CYCreditTool timewithLongLongValue:record.endTime.longLongValue formatter:nil];
        self.lastPayTime.text = CYStringFormat(@"最终还款时间：%@", end);
    } else {
        self.lastPayTime.text = CYStringFormat(@"最终还款时间：%@", @"逾期未还");
    }

    if (record.status) {
        int statusInt = record.status.intValue;
        if (statusInt == 1) {
            self.submitStatus.text = @"已提交";
            self.submitStatus.textColor = [UIColor grayColor];
        } else if (statusInt == -1) {
            self.submitStatus.text = @"已删除";
            self.submitStatus.textColor = [UIColor grayColor];
        } else if (statusInt == 0) {
            self.submitStatus.text = @"未提交";
            self.submitStatus.textColor = [UIColor redColor];
        }
    } else {
        self.submitStatus.text = @"";
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
